<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */

    /*********************************************************
    *            --== InArch ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 22.04.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * Class adminAjax
    ****
    * This is the ajax resolution interface.
    ****
    * @package adminModules
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.05.2005
    * @copyright essentialmind.com 2005
    ***/
    class adminAjax extends adminModule{

        /**
         * adminAjax::process()
         *
         * Process inputs
         *
         * @return void
         **/
        public function process(){

            //check if the action is defined
            if(!isset($_GET['action'])){
                throw new exception("No Ajax action is defined!",500);
            }

            $this->log->recordAction("Ajax request: ".$_GET['action']);

            //see if the needed object is in place
            if( !file_exists(INA_ROOT.'classes'.DIRECTORY_SEPARATOR.'ajax'.DIRECTORY_SEPARATOR.'ajax'.ucfirst($_GET['action'].'.class.php')) and
                !file_exists(ROOT.'classes'.DIRECTORY_SEPARATOR.'ajax'.ucfirst($_GET['action'].'.class.php'))){
                throw new exception("No Ajax action \"".$_GET['action']."\" is defined!");
            }else{
                $ajaxAction = 'ajax'. ucfirst($_GET['action']);
            }

            //create ajax action handler
            $myAjax = new $ajaxAction($this->db,$this->smarty,$this->log);

            //process ajax request
            echo $myAjax->process();

            //terminate script
            exit;
        }


        /**
         * adminAjax::setTemplate()
         *
         * set the action template to index.html
         *
         * in fact, the ajax interface never gets to displaying a
         * template, as this is a text resolution protocol
         *
         * @return void
         **/
        public function setTemplate(){
            $this->setActionTemplate('index.html');
        }
    }
?>